package com.zheng.study.company.entity;

import javax.persistence.*;
import java.util.Set;

/**
 * 部门
 * ============================================================================
 * author : dzw
 * createDate:  2018/8/24 。
 * ============================================================================
 */
//@Entity
//@Table(name = "sys_department")
public class Department extends CompanyEntity {
	private static final long serialVersionUID = -9079657385170065810L;

	/**
	 * 部门代码
	 */
	private String code;
	/**
	 * 描述
	 */
	private String description;
	/**
	 * 父节点
	 */
	private Department parent;
	/**
	 * 子节点
	 */
	private Set<Department> children;
	/**
	 * 包含的岗位
	 */
	private Set<Post> postSet;
	/**
	 * 路径
	 */
	private String path;
	/**
	 * 层级
	 */
	private int grade;
	/**
	 * 职权
	 */
	private Set<Power> powerSet;
	/**
	 * 排序
	 */
	private int sortNo;
	/**
	 * 部门负责人
	 */
	private Duty leader;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(length = 4000)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public Department getParent() {
		return parent;
	}

	public void setParent(Department parent) {
		this.parent = parent;
	}

	@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY)
	@OrderBy("name asc")
	public Set<Department> getChildren() {
		return children;
	}

	public void setChildren(Set<Department> children) {
		this.children = children;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@OrderBy("name asc")
	public Set<Post> getPostSet() {
		return postSet;
	}

	public void setPostSet(Set<Post> postSet) {
		this.postSet = postSet;
	}

	@OneToMany(mappedBy = "department", fetch = FetchType.LAZY)
	@OrderBy("name asc")
	public Set<Power> getPowerSet() {
		return powerSet;
	}

	public void setPowerSet(Set<Power> powerSet) {
		this.powerSet = powerSet;
	}

	@Column(length = 4000)
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public int getSortNo() {
		return sortNo;
	}

	public void setSortNo(int sortNo) {
		this.sortNo = sortNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	public Duty getLeader() {
		return leader;
	}

	public void setLeader(Duty leader) {
		this.leader = leader;
	}
}
